<?php

namespace App\Models;


use Illuminate\Database\Eloquent\Model;

class ClassCard extends Model
{

    protected $table = 'class_card';
    public $timestamps = false;


    static function getCardById($id){
       return self::where('user_id',$id)->orderby('created_at','desc')->first(['card_id','status']);
    }

    //我的订单
        public static function getMyOrder($uid){
        $res =  self::where('user_id',$uid)->select('created_at','status','card_id')->orderby('created_at','desc')->get() ?? '';
        if ($res){
            foreach ($res as $k=>&$v){
                $cardInfo = CardList::getDetail($v->card_id);
                $v->card_name = $cardInfo['card_name'];
                $v->card_price = $cardInfo['card_price'];
                $v->time = $cardInfo['time'];
                $v->created_at = date('Y-m-d H:i:s',$v->created_at);
            }
     }
        return $res;
    }



}
